package main

import (
	"CloudNavtive/HttpServer/config"
	"fmt"
	"net/http"
	"os"

)


func handler(w http.ResponseWriter, r *http.Request){
	for k, v := range r.Header{
		for _, value := range v {
			w.Header().Set(k, value)
		}
	}
	ver := os.Getenv("VERSION")
	w.Header().Set("version", ver)
	config.Logger.Printf("%s,", r.RemoteAddr)
}

func handlertz(w http.ResponseWriter, r *http.Request){
	
	config.Logger.Printf("%s,", r.RemoteAddr)
	w.WriteHeader(http.StatusOK)
}

func main(){
	fmt.Println("server begin")
	http.HandleFunc("/", handler)
	http.HandleFunc("/healthz", handlertz)
	http.ListenAndServe("localhost:8080", nil)
}

